package controller.link.game;

import view.client.Console;
import model.Hearer;
import view.client.PanelGame;
import java.io.Serializable;
import controller.Link;
import model.Attendant;
import model.Server;

public class Ask4SvInfo implements Link, Serializable {

    private int usersOnline;
    private int totalPlayers;

    public Ask4SvInfo() {
    }

    public Ask4SvInfo(Hearer h) {
        h.send((Link) this);
    }

    @Override
    public void serverUse(Server server, Attendant at) {
        usersOnline = server.getAttendants().size();
        totalPlayers = server.getWorld().getMap().getTotalPlayers();
        at.send((Link) this);
    }

    public int getUsersOnline() {
        return usersOnline;
    }

    public int getTotalPlayers() {
        return totalPlayers;
    }

    @Override
    public void clientUse(Console console) {
        PanelGame pg = console.getPg();
        pg.getLblOn().setText("Players Online: " + usersOnline);
        pg.getLblTotal().setText("Total Players: " + totalPlayers);
        pg.revalidate();
        console.getFrame().repaint();
    }
}
